package com.galeno.zoopeeper;

import org.apache.zookeeper.CreateMode;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooDefs;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author galeno @Title: @Description:
 * @date 2021/7/3017:06
 */
public class Demo0 {
  public static void main(String[] args) throws IOException, InterruptedException, KeeperException {
    ZooKeeper zk = new ZooKeeper("galeno01:2181,galeno02:2181,galeno03:2181", 10000, null);
    byte[] bytes = "nage".getBytes();
    /** 参数1:路径 /开头 参数2:值 字节数组 参数3 权限 参数4 节点类型 */
    // String s = zk.create("/fff", bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT);
    String s =
        zk.create("/fff", bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL);
    System.out.println(s);
    zk.close();
  }
}
